<template>
  <dialog-editor ref="dialog"></dialog-editor>
</template>

<script>
import DialogEditor from '@/components/DialogEditor'
import dialogMixins from '@/utils/commonDialogMixins'

export default {
  mixins: [dialogMixins],
  components: {DialogEditor},
  data() {
    return {
      dataFormConfig: {
        id: {
          hidden: true
        },
        warehouseId: {
          label: '仓库',
          type: 'list',
          placeholder: '请选择仓库',
          list: []
        },
        shelfNo: {
          label: '架号',
          placeholder: '请输入架号'
        },
        levelNo: {
          label: '层号',
          placeholder: '请输入层号'
        },
        isEmpty: {
          label: '是否有货',
          type: 'switch',
          activeValue: 1,
          inactiveValue: 0,
          default: 0
        }
        // modelId: {
        //   label: '模具id',
        //   placeholder: '请输入模具id'
        // }
      }
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0
      this.initWareHouseList()

      this.$refs.dialog.initDialog({
        dataForm: this.dataForm,
        config: this.dataFormConfig,
        dataRule: this.getNeedDataRule('warehouseId', 'shelfNo', 'isEmpty', 'modelId'),
        initApi: 'modelApi/modelShelfInfo',
        saveApi: 'modelApi/saveModelShelf',
        updateApi: 'modelApi/updateModelShelf',
        objectName: 'modelShelf'
      })
    }
  }
}
</script>
